<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>添加/修改页面</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="../../../component/elementUI/index.css">
    <link rel="stylesheet" href="../../../component/pear/css/pear.css" />
    <link rel="stylesheet" href="../../../style/wangeditor.css">
    <link rel="stylesheet" href="../../../style/index.css">
</head>

<body>
    <div id="app" v-cloak>
        <div class="add">
            <div class="header">
                <span>{{(action == 'Add'?'添加':'修改')}}入库信息</span>
            </div>
            <div class="main" style="padding: 0 15px;">
                <!-- 配置属性, 目前仅支持 单主表 多子表 结构 -->
                <div id="form" :data-options="JSON.stringify({'tableName':'purchase_receipt','formName':'dataForm' ,'primaryKey':'Purchase_Receipt_SerialNumber'})">
                    <!-- 子表 -->
                    <div :data-options="JSON.stringify({'tableName':'purchase_receipt_detail','formName':'childDataForm', 'parentTableName':'purchase_receipt'})"></div>
                </div>

                <div class="table_titel">
                    <div class="titel">入库信息</div>
                </div>
                <el-form :model="dataForm" ref="form" :inline-message="true" style="width: 100%">
                    <el-descriptions :column="2" size="large" border>
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">采购入库流水号</div>
                            </template>
                            <el-form-item prop="Purchase_Receipt_SerialNumber" :rules="[{ required: true, message: '请输入采购入库流水号', trigger: 'blur' }]">
                                <el-input v-model.trim="dataForm.Purchase_Receipt_SerialNumber" placeholder="请输入 采购入库流水号" clearable></el-input>
                            </el-form-item>
                        </el-descriptions-item>

                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">入库日期</div>
                            </template>
                            <el-form-item prop="Receipt_Date" :rules="[{ required: true, message: '请输入入库日期', trigger: 'blur' }]">
                                <el-date-picker v-model.trim="dataForm.Receipt_Date" type="date" value-format="yyyy-MM-dd" placeholder="请选择入库日期"></el-date-picker>
                            </el-form-item>
                        </el-descriptions-item>

                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">存货地点</div>
                            </template>
                            <el-form-item prop="Receipt_Type" :rules="[{ required: true, message: '请输入存货地点', trigger: 'blur' }]">
                                <el-input v-model.trim="dataForm.Receipt_Type" placeholder="请输入存货地点" clearable></el-input>
                            </el-form-item>
                        </el-descriptions-item>	

                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">仓库编号</div>
                            </template>
                            <el-form-item prop="Store_SerialNumber" :rules="[{ required: true, message: '请输入仓库编号', trigger: 'blur' }]">
                                <el-input v-model.trim="dataForm.Store_SerialNumber" placeholder="请输入仓库编号" clearable></el-input>
                            </el-form-item>
                        </el-descriptions-item>
                        
                    </el-descriptions>
                </el-form>

                <div class="table_titel">
                    <div class="titel">入库信息</div>
                    <div class="operation">
                        <el-button type="primary" size="small" @click="handleAdd('childDataForm')">新增</el-button>
                        <el-button type="danger" size="small" @click="handleRemove('childDataForm')">删除</el-button>
                    </div>
                </div>

                <el-form :model="{childDataForm:childDataForm.filter(i=>i.Row_Status != '1')}" ref="childForm" 
                    :inline-message="true" style="width: 100%">
                    <el-descriptions :column="2" size="large" border 
                        v-for="(item,index) in childDataForm.filter(i=>i.Row_Status != '1')" :key="index">
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">采购入库明细流水号</div>
                            </template>
                            <el-form-item :prop="`childDataForm.${index}.Purchase_Receipt_Detail_SerialNumber`" :rules="[{ required: true, message: '请输入 article serial number', trigger: 'blur' }]">
                                <el-input v-model.trim="item.Purchase_Receipt_Detail_SerialNumber" placeholder="请输入采购入库明细流水号" clearable></el-input>
                            </el-form-item>
                        </el-descriptions-item>

                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">采购入库流水号</div>
                            </template>
                            <el-form-item :prop="`childDataForm.${index}.Purchase_Order_SerialNumber`" :rules="[{ required: true, message: '请输入 article serial number', trigger: 'blur' }]">
                                <el-input v-model.trim="item.Purchase_Order_SerialNumber" placeholder="请输入采购入库流水号" clearable></el-input>
                            </el-form-item>
                        </el-descriptions-item>

                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">商品流水号</div>
                            </template>
                            <el-form-item :prop="`childDataForm.${index}.Article_SerialNumber`" :rules="[{ required: true, message: '请输入商品流水号', trigger: 'blur' }]">
                                <el-input v-model.trim="item.Article_SerialNumber" placeholder="请输入商品流水号" clearable></el-input>
                            </el-form-item>
                        </el-descriptions-item>

                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">入库数量</div>
                            </template>
                            <el-form-item :prop="`childDataForm.${index}.Receipt_Quantity`" :rules="[{ required: true, message: '请输入入库数量', trigger: 'blur' }]">
                                <el-input v-model.trim="item.Receipt_Quantity" @input="handleReceiptQuantityChange(index, item)" placeholder="请输入入库数量" clearable></el-input>
                            </el-form-item>
                        </el-descriptions-item>
                        
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">剩余数量</div>
                            </template>
                            <el-form-item :prop="`childDataForm.${index}.Remain_Quantity`" :rules="[{ required: true, message: '请输入剩余数量', trigger: 'blur' }]">
                                <el-input v-model.trim="item.Remain_Quantity" placeholder="请输入剩余数量" readonly></el-input>
                            </el-form-item>
                        </el-descriptions-item>

                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">过期时间</div>
                            </template>
                            <el-form-item :prop="`childDataForm.${index}.Expiration_Date`" :rules="[{ required: true, message: '请输入过期时间', trigger: 'blur' }]">
                                <el-date-picker v-model.trim="item.Expiration_Date" type="date" value-format="yyyy-MM-dd" placeholder="请选择过期时间"></el-date-picker>
                            </el-form-item>
                        </el-descriptions-item>

                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">商品单价</div>
                            </template>
                            <el-form-item :prop="`childDataForm.${index}.Amount`" :rules="[{ required: true, message: '请输入商品单价', trigger: 'blur' }]">
                                <el-input v-model.trim="item.Amount" placeholder="请输入商品单价" clearable></el-input>
                            </el-form-item>
                        </el-descriptions-item>
                        

                    </el-descriptions>
                </el-form>
            </div>
            <div class="footer">
                <el-button size="medium" @click="handleBack">返回</el-button>
                <el-button size="medium" type="primary" plain @click="handleSubmit" :loading="loading">提交</el-button>
            </div>
        </div>
    </div>
    <script type="text/javascript" src="../../../utils/wangeditor.js"></script>
    <script type="text/javascript" src="../../../utils/xlsx.full.min.js"></script>
    <script type="text/javascript" src="../../../utils/jquery.min.js"></script>
    <script type="text/javascript" src="../../../utils/jquery.cookie.js"></script>
    <script type="text/javascript" src="../../../utils/vue.min.js"></script>
    <script type="text/javascript" src="../../../utils/vuex.min.js"></script>
    <script type="text/javascript" src="../../../component/elementUI/index.js"></script>
    <script type="text/javascript" src="../../../utils/components.js"></script>
    <script type="text/javascript" src="../../../utils/compressor.js"></script>
    <script type="text/javascript" src="../../../utils/validity.js"></script>
    <script type="text/javascript" src="../../../utils/utils.js"></script>
    <script type="text/javascript" src="../../../utils/http.js"></script>
    <script type="text/javascript" src="js/add.js"></script>
</body>

</html>